-
Notifications
You must be signed in to change notification settings - Fork 324
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Checking ascribed expression types for existence #7796
Checking ascribed expression types for existence #7796
Conversation
m = a*b | ||
add p m | ||
p:Plus + m:Plus |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simplifies requesting conversions into desired types by using inline expressions p:Plus
and m:Plus
. Simpler than defining add (x:Plus) (y:Plus)
method and requesting conversion of its arguments.
Jaroslav Tulach reports a new STANDUP for yesterday (2023-09-12): Progress: -
Next Day: Finish |
@@ -202,6 +212,19 @@ spec = | |||
to_6 (v : Number & Decimal & Integer) = v | |||
to_6 m . should_equal 1.5 | |||
|
|||
Test.specify "Requesting Integer & Fool" <| | |||
do_stuff (x : Integer & Fool) = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copy of test provided by @radeusgd with slight modifications using x:Integer
to hint the system.
Implementing ==
for multi value was a bit tricky - it is a method on Any
and thus each value supports it. But at least the ==
and to_text
work fine since 2bc7dd3 - the solution is to invoke all Any
methods on the multi value as a whole.
TruffleObject that, | ||
@CachedLibrary(limit = "3") InteropLibrary iop, | ||
@Cached AddNode delegate) { | ||
try { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will have to add this code into all arithmetic nodes, so @Akirathan, @hubertp & co. please review if dad0fb1 is OK.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nits
engine/runtime/src/main/scala/org/enso/compiler/codegen/IrToTruffle.scala
Outdated
Show resolved
Hide resolved
...ntime/src/main/java/org/enso/interpreter/node/expression/builtin/number/integer/AddNode.java
Outdated
Show resolved
Hide resolved
engine/runtime/src/main/java/org/enso/interpreter/runtime/data/EnsoMultiValue.java
Show resolved
Hide resolved
import org.junit.runner.RunWith; | ||
import org.junit.runners.Parameterized; | ||
|
||
@RunWith(Parameterized.class) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Akirathan, originally I was using @Theories
, but after reading this stackoverflow post:
A Theory is wrong if a single test in it is wrong, according to the definition of a Theory. If your test cases don't follow this rule, it would be wrong to call them a "Theory".
and after realizing theories are in experimental
package, I decided to switch to @Parametrized. The way to specify parameters()
isn't as nice as in case of theories, but unlike the academical theory activists I believe running all the test is what real developers want. I seem to like proper error reports more then purity.
Don't you want to migrate to @Parametrized
too?
var r = new Random(); | ||
var ops = Arrays.asList(OPERATIONS).stream().map( | ||
(op) -> new Object[] { op, r.nextLong(), switch (op) { | ||
case " ^" -> r.nextLong(10); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is a bit dangerous to let the right hand side argument of ^
to be Long.MAX_VALUE
;-)
Co-authored-by: Hubert Plociniczak <[email protected]>
597cb3f
to
04a1d14
Compare
I tried to update documentation, but this types document is just completely off:
;-)
|
Pull Request Description
Fixes #6848 by:
a:Xyz
exists or yielding an error otherwisea:Integer
is checked at runtimeImportant Notes
Checklist
Please ensure that the following checklist has been satisfied before submitting the PR:
Scala,
Java,